package com.lyx.user.controller;


import com.lyx.common.exception.ExceptionEnum;
import com.lyx.common.result.R;
import com.lyx.common.result.Result;
import com.lyx.common.result.ResultUtil;
import com.lyx.user.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 发送短信
 * @author 14667
 * @date 2022/7/18 18:02
 */
@RestController
@RequestMapping("/sms")
public class SmsController {
    @Autowired
    private SmsService smsService;

    /**
     * 验证码发送
     * @param phone
     * @return
     */
    @PostMapping("/sendCode")
    public R sendCode(@RequestParam(defaultValue = "") String phone){
        boolean send = smsService.send(phone);
        if(send){
            return R.ok().message("发送验证码成功");
        }else{
            return R.error().code(ExceptionEnum.CODE_ERROR.getCode()).message(ExceptionEnum.CODE_ERROR.getMsg());
        }

    }
}
